if package_root.join(&default_bin_path.0).exists() {
default_bin_path // inferred from bin's name
} else {
- PathValue(Path::new("src").join("main.rs"))
+ let path = PathValue(Path::new("src").join("main.rs"));
+ if package_root.join(&path.0).exists() {
+ path
+ } else {
+ PathValue(Path::new("src").join("bin").join("main.rs"))
+ }
}
});
let mut target = Target::bin_target(&bin.name(), package_root.join(&path.0),
assert_that(p.cargo_process("run").arg("--bin").arg("other"),
execs().with_status(0));
}
+
+#[test]
+fn run_proper_binary_main_rs() {
+ let p = project("foo")
+ .file("Cargo.toml", r#"
+ [package]
+ name = "foo"
+ authors = []
+ version = "0.0.0"
+ [[bin]]
+ name = "foo"
+ "#)
+ .file("src/lib.rs", "")
+ .file("src/bin/main.rs", r#"
+ fn main() {
+ }
+ "#);
+
+ assert_that(p.cargo_process("run").arg("--bin").arg("foo"),
+ execs().with_status(0));
+}